package by.kniazhych.core.server.local.data {
	import by.kniazhych.core.constants.PeaceType;
	import by.kniazhych.core.data.game.PeacePosition;
	
	/**
	 * ...
	 * @author Boutylin Mikhail
	 */
	
	
	
	public class MotionCommand implements ICommand{
		
		private var _data:Array;
		private var _oldStartState:uint;
		private var _oldFinalState:uint;
		private var _sP:PeacePosition;
		private var _fP:PeacePosition;
		
		public function MotionCommand(sP:PeacePosition, fP:PeacePosition) {
			_fP = fP;
			_sP = sP;
			
		}
		
		/* INTERFACE by.kniazhych.core.server.local.data.ICommand */
		
		public function execute(data:Array):void {
			_data = data;
			_oldStartState = _data[_sP.y][_sP.x];
			_oldFinalState = _data[_fP.y][_fP.x];
			_data[_sP.y][_sP.x] = PeaceType.BLANK_CELL;
			_data[_fP.y][_fP.x] = _oldStartState;
			
			
		}
		
		public function undo():void {
			_data[_sP.y][_sP.x] = _oldStartState;
			_data[_fP.y][_fP.x] = _oldFinalState;
		}
		
		
		
	}

}